home *** CD-ROM | disk | FTP | other *** search
/ Asymetrix Multimedia Toolbook 4.0 (CBT Edition) / Asymetric Multimedia Toolbook 4.0 (CBT Edition).iso / ctb40sm.z / MAPI.TBK (.txt) < prev    next >
Asymetrix ToolBook File  |  1995-11-13  |  92KB  |  1,721 lines

  1. Counting Messages
  2. Checking For Unread Mail
  3. Using MAPI
  4. Using MAPI+
  5. Microsoft's Messaging Application Programming Interface (MAPI) is a set of high level DLL functions that are the foundation of electronic mail in Windows. Applications use these functions to create, manipulate, transfer, and store messages.
  6. The scripts and examples in this book demonstrate how to access MAPI from ToolBook, but are not intended to teach you MAPI. It is assumed that you are familiar with and have documentation for MAPI.
  7. The handlers which directly access the MAPI functions are all found in the script of this book.s which applications used to create, manipulate, transfer, and store messages. Most of these functions are exported from MAPI.DLL and form the basis for electronic mail in Windows.
  8. The scripts and examples in this book demonstrate how to access MAPI from ToolBook, but are not intended to teach MAPI to the user. In fact. it is assumed that user is familiar with and has documentation for MAPI.
  9. The handlers which directly access the MAPI functions are all found in the book script.
  10. Sending Messages
  11. Sending Messages
  12. Sending Messages5
  13. The example below illustrates how to send a message without using the MAPI dialog box. Fill in the fields below and click the button when you are ready to send the message..the message.
  14. Send Message
  15. .'+    +F
  16. .'+    +F
  17. }str_sent
  18. getAddress
  19. sendMessage
  20. s_MAPIError
  21. str_notSent
  22. buttonClick
  23. buttonClick
  24. 4s_MAPIError
  25. there 
  26. no recipient supplied
  27.         -- call up 
  28. 6 Address Book
  29. getAddress()
  30.         -- 
  31. we don't 
  32. address we won't 
  33. a message
  34.         -- fill 
  35.  appropriate 
  36. sendMessage(
  37. "sub",
  38. "body")
  39.     -- confirm whether 
  40.  was sent
  41. str_notSent()&&
  42. str_sent()
  43. &Send Message
  44. Bob N.
  45. We're almost there now.
  46. Don't blow it!
  47. Subject:
  48. Text:
  49. Submit Reports
  50. Receive Reports
  51. Receive Reports
  52. View New
  53. uupdateMessages
  54. buttonClick
  55. buttonClick
  56.     -- scan incoming mail 
  57. problem reports 
  58. setup the 
  59.     -- (
  60. message 
  61. handled 
  62. updateMessages 
  63. &View New
  64. delete
  65. [4deleteMessage
  66. uupdateMessages
  67. str_OK
  68. s_MsgHandles
  69. s_MsgNum
  70. s_MAPIError
  71. Rstr_notDelete
  72. buttonClick
  73. buttonClick
  74. 4s_MsgNum,s_MsgHandles,s_MAPIError
  75.     -- delete the current message
  76. deleteMessage(
  77. <> str_OK()
  78. str_notDelete()&&
  79.     -- refresh 
  80. [ list 
  81.     -- (
  82. handled 
  83. updateMessages 
  84. D&elete
  85. Previous
  86. 8parseMsgText
  87. s_MsgNum
  88. buttonClick
  89. buttonClick
  90. 4s_MsgNum
  91. mail message
  92. disable 
  93. G = 1
  94.         enabled 
  95. B"Next" = 
  96.     -- fill 
  97. ~fields 
  98.     -- (
  99. handled 
  100. parseMsgText
  101. &Previous
  102. Previous
  103. 8parseMsgText
  104. s_MsgCount
  105. s_MsgNum
  106. buttonClick
  107. buttonClick
  108. 4s_MsgNum,s_MsgCount
  109. tmessage
  110. , disable 
  111.         enabled 
  112. B"Previous" = 
  113.     -- fill 
  114. fields 
  115.     -- (
  116. handled 
  117. parseMsgText
  118. &Next
  119. Submit Reports
  120. Submit Reports
  121. buttonClick
  122. buttonClick
  123. "Submit Reports"
  124. &Submit Reports
  125. examples
  126. buttonClick
  127. buttonClick
  128. the example 
  129. Fclose 
  130. isOpen 
  131. "examples"
  132. &Done
  133. toLabel
  134. From:ss:
  135. problem
  136. Department
  137. address
  138. msgnum
  139. No messagesf 10
  140. toLabel
  141. Department:
  142. office
  143. phone
  144. toLabel
  145. Problem Area:
  146. toLabel
  147. Phone::::::::
  148. toLabel
  149. Office: Area:
  150. toLabel
  151. Description of problem:
  152. description
  153. toLabel
  154. Sent:ss:
  155. timestamp
  156. Example: Problem Reports
  157. *ClassTbl*
  158. *ClassEntry*
  159. *PTABLE*
  160. *WINDOWSEG*
  161. Viewer
  162. *ICONRESTAB*
  163. *ICONRESSEG*
  164. *ICONRES*
  165. Background
  166. *OBJTABLE*
  167. *IDTABLE*
  168. *NAMETAB*
  169. Rectangle
  170. Ellipse
  171. RoundedRectangle
  172. Polygon
  173. IrregularPolygon
  174. AngledLine
  175. Curve
  176. Field
  177. RecordField
  178. ComboBox
  179. Button
  180. PaintObject
  181. Picture
  182. Hotword
  183. *RHOTWORD*
  184. Group
  185. Stage
  186. *TbxBase*
  187. functions
  188. MAPIFindNext(
  189. , 0, 0, 
  190.         -- 
  191. Verifying Names
  192. -- a notify handler was used 
  193. the address 
  194. you enter 
  195. Verifying Names
  196. Verifying Names
  197. Click Check Names to get the full names of those displayed in the upper field and place them in the lower field.
  198. If a name is ambiguous, MAPI displays a dialog box that allows the user to choose the correct name.opriate... field. 
  199. If a name is ambiguous, MAPI will display a dialog allowing the user to choose which name is appropriate.
  200. Check Names
  201. 1,    #>
  202. checkNames
  203. partial
  204. s_MAPIError
  205. str_notResolved
  206. buttonClick
  207. buttonClick
  208. 4s_MAPIError
  209. a list 
  210. verified names 
  211. checkNames(
  212. "partial")
  213. error condition
  214. "full" = 
  215.         -- 
  216. some 
  217. hcould 
  218. xbe resolved:
  219.         -- the 
  220. value 
  221.         --    
  222. those that 
  223.         -- 
  224.         --    
  225. ,were 
  226. str_notResolved()&
  227. &Check Names
  228. partial
  229. Tom,Dick,Harry
  230. enterPage
  231. notifybefore 
  232. = "Tom,Dick,Harry"
  233. Tom,Dick,Harryelda
  234. enterPage
  235. notifybefore 
  236. enterPage
  237. examples
  238. Linking to MAPI.DLL
  239. Sending Messages
  240. Checking For Unread Mail
  241. -- notify handlers were used 
  242. [the fields 
  243. -- you enter 
  244. Checking For Unread Mail
  245. Checking For Unread Mail
  246. The script of this button steps through the messages in your incoming mail folder, looking for unread messages. The sender and subject of each unread message are placed in the fields below.. fields.
  247. Check for Unread Mail
  248. eck for Unread Mail
  249. Messages
  250. text area
  251. textScrolled
  252. buttonUp
  253. the fields together
  254. -- There are three 
  255. order 
  256. these 
  257. -- smoothly, 
  258. filled 
  259. fdummy 
  260. which has 
  261. -- same 
  262. other 
  263. . Only 
  264. b. When 
  265. scrolled, 
  266. 2two 
  267. -- If there were only 
  268. bar would 
  269. textScrolled 
  270. oselectedtextlines = 
  271. scrollbar
  272. enterPage
  273. notifybefore 
  274. Subject
  275. enterPage
  276. notifybefore 
  277. enterPage
  278. notifybefore 
  279. From:
  280. Subject:
  281. enterPage
  282. &Check for Unread Mail
  283. functions
  284. functions
  285. linkdll "mapi.dll"
  286.    DWORD MAPILogoff (DWORD, DWORD, DWORD, DWORD)
  287.    DWORD MAPILogon (DWORD, STRING, STRING, DWORD, DWORD, POINTER)
  288.    DWORD MAPIFindNext (DWORD, DWORD, DWORD, POINTER, DWORD, DWORD, \
  289.                                         POINTER)
  290.    DWORD MAPIFreeBuffer (POINTER)
  291.    DWORD MAPISendMail (DWORD, DWORD, POINTER, DWORD, DWORD)
  292.    DWORD MAPIReadMail (DWORD, DWORD, STRING, DWORD, DWORD, POINTER)
  293.    DWORD MAPIResolveName (DWORD, DWORD, STRING, DWORD, DWORD,  \
  294.                                               POINTER)        
  295.    DWORD MAPISendDocuments (DWORD, STRING, STRING, STRING, DWORD)    
  296.    DWORD MAPIAddress (DWORD, DWORD, STRING, DWORD, STRING, DWORD, \
  297.                                       DWORD, DWORD, DWORD, POINTER, POINTER)
  298.    DWORD MAPIDeleteMail (DWORD,DWORD,STRING,DWORD,DWORD)
  299. end linkDLL,STRING,DWORD,DWORD)
  300. end linkDLL
  301. buttonClick
  302. buttonClick
  303. isOpen 
  304. "link"
  305.         close 
  306. functions
  307. buttonClick
  308. Bcopies 
  309. clipboard
  310. buttonClick
  311.     -- place 
  312. "functions"
  313.     -- take 
  314. B"ok"
  315. &Copy to Clipboard
  316. &File
  317. &Open...    Ctrl+O
  318. &Save    Ctrl+S
  319. Save &As...
  320. saveas
  321. Print Set&up...
  322. printsetup
  323. &Print Pages...    Ctrl+P
  324. printpages
  325. &Run...
  326. E&xit    Alt+F4
  327. &Edit
  328. &Undo    Ctrl+Z
  329. Cu&t    Ctrl+X
  330. &Copy    Ctrl+C
  331. &Paste    Ctrl+V
  332. paste
  333. C&lear    Del
  334. clear
  335. Aut&hor    F3
  336. author
  337. &Page
  338. &Next    Alt+Right
  339. &Previous    Alt+Left
  340. previous
  341. &Menu    Alt+Up
  342. first
  343. &Help
  344. &Contents    F1
  345. contents
  346. g: fs2/vo
  347. Linking to MAPI.DLL
  348. Linking to MAPI.DLL
  349. The functions for handling messages in Windows are exported from MAPI.DLL. Click View DLL Functions to see the way these functions are prototyped in OpenScript.ped in OpenScript.
  350. buttonClick
  351. buttonClick
  352. display a 
  353. which 
  354.     -- linking information
  355. &View DLL Functions
  356. Composing Mail
  357. Composing Mail
  358. Composing Mail
  359. Click Compose Message to open the MAPI dialog box you use to compose and send a message.
  360. Click Attach a File if you want to attach a file to the message you compose.....se buttons bring up the MAPI dialog box allowing you to compose and send a message.
  361. The second button attaches a file to the message that you compose.
  362. Compose Message
  363. s_MAPIError
  364. ucomposeMessage
  365. buttonClick
  366. buttonClick
  367. 4s_MAPIError
  368.     -- compose a message
  369. composeMessage()
  370. returned - 
  371. error condition
  372. k <> 
  373. &Compose Message
  374. Attach a File
  375. filename
  376. ZsendFile
  377. s_MAPIerror
  378. buttonClick
  379. buttonClick
  380. 4s_MAPIerror
  381.     -- compose a message 
  382. attached file
  383. sendFile(
  384. "filename")
  385. returned - 
  386. b condition
  387. s_MAPIError <> 
  388. &Attach a File
  389. filename
  390. enterPage
  391. notifyBefore 
  392. C:\JX\MAPI\MAPI.TBKKKKKKKBK
  393. enterPage
  394. Composing Mail
  395. Looking up Addresses
  396. Verifying Names
  397. Counting Messages
  398. Counting Messages
  399. Counting Messages
  400. Click the appropriate button below to count the messages in your incoming mail folder.by stepping through them one at a time.il folder by stepping through them one at a time. This first counts all messages, and the seconds counts only unread messages.
  401. Count All Messages
  402. .'+    +F
  403. .'+    +F
  404. FALSE
  405. str_msgCountAll
  406. l'getNextMsgID
  407. 1RgetFirstMsgID
  408. buttonClick
  409. buttonClick
  410. ZLONG count
  411. the ID 
  412. message (read 
  413. unread)
  414. getFirstMsgID(FALSE)
  415. found
  416.         -- 
  417. getNextMsgID(
  418. str_msgCountAll(
  419. Count &All Messages
  420. Count Unread Messages
  421. .'+    +F
  422. .'+    +F
  423. l'getNextMsgID
  424. Dstr_msgCountUnread
  425. 1RgetFirstMsgID
  426. buttonClick
  427. buttonClick
  428. ZLONG count
  429. the ID 
  430. message (read 
  431. unread)
  432. getFirstMsgID(TRUE)
  433. found
  434.         -- 
  435. getNextMsgID(
  436. str_msgCountUnread(
  437. Count &Unread Messages
  438. message
  439. str_of
  440. Problem Report
  441. str_problemRep
  442. Aborting operation: Me
  443. Arial
  444. Arial
  445. Arial
  446. Arial
  447.  Sans Serif
  448. Arial
  449. Arial
  450. MS Sans Serif
  451. ge id 23
  452. examples
  453. Page "Submit Reports"
  454. MAPI Tutorial
  455. Page "functions"
  456. examples
  457. Submit Reports
  458. department
  459. Salestingnt
  460. Development
  461. Executive
  462. Finance
  463. Marketing
  464. Sales
  465. Technical Support
  466. Testings
  467. problem
  468. Hardware Problemtion
  469. E-Mail
  470. Hardware Installation
  471. Hardware Problem
  472. Network
  473. Other
  474. Phones
  475. Printers
  476. Software Installation
  477. Software Problem
  478. office
  479. phone
  480. x3434
  481. description
  482. My machine won't boot right. The disk keeps running and running but nothing happens.
  483. Change Address
  484. nameList
  485. getAddress
  486. buttonClick
  487. buttonClick
  488.     -- call up the Addressbook dialog 
  489. a list 
  490. names
  491.     nameList = getAddress()
  492. namelist 
  493. &Change Address
  494. Receive Reports
  495. Receive Reports
  496. buttonClick
  497. buttonClick
  498. "Receive Reports"
  499. ceive Reports
  500. examples
  501. buttonClick
  502. buttonClick
  503. the example 
  504. Fclose 
  505. isOpen 
  506. "examples"
  507. &Done
  508. Jim Geldmacher
  509. str_problemRep
  510. enterPage
  511. subject 
  512. standard 
  513. reports
  514. notifybefore 
  515. = str_problemRep()
  516. Problem Report
  517. toLabel
  518. Address:
  519. toLabel
  520. Subject:
  521. toLabel
  522. Department:
  523. toLabel
  524. Problem Area:
  525. toLabel
  526. Phone::::::::
  527. toLabel
  528. Office: Area:
  529. toLabel
  530. Description of problem:
  531. Submit Report
  532. Office:
  533. Department:
  534. phone
  535. description
  536. problem
  537. Problem Report
  538. Phone:
  539. Description:
  540. Problem:
  541. sendMessage
  542. nstr_notSubmit
  543. s_MAPIError
  544. office
  545. department
  546. str_submit
  547. buttonClick
  548. buttonClick
  549. 4s_MAPIError
  550. ZmsgTxt
  551.     -- build the 
  552. message
  553. ' = "Problem Report"
  554. D = "Department:"
  555. combobox "department"
  556. 3problem"
  557.  = "Office:"
  558. "office"
  559.  = "Phone:"
  560. "phone"
  561.  = "Description:"
  562. "description" 
  563. sendMessage(
  564. "sub",
  565. str_notSubmit()&&
  566. str_submit()
  567. bmit Report
  568. enterPage
  569. &Submit Report
  570. &Receive Reports
  571. ~HVHVH
  572.  1993,1994. Asymetrix Corporation. All Rights Reserved.
  573. -- Author: Jim Geldmacher
  574. Mgives you permission 
  575. e, revise, 
  576. reuse the
  577. -- individual 
  578. scripts 
  579. your own
  580. -- applications.
  581. You may 
  582. H entire 
  583. -- substantial part 
  584. redistribution 
  585. ` product.
  586. retains 
  587.  copyright on 
  588.  original elements 
  589.  . Include 
  590.  notice
  591. --     "Portions 
  592.  1993, 1994. 
  593. they contain 
  594. copied 
  595. -- Standard ToolBook messages
  596. enterApplication
  597. xsysRuntime
  598.     -- link 
  599.  DLLs
  600. initLinks
  601. MAPI 
  602. available 
  603. isMAPIAvailable()
  604. SessionLogon()
  605. str_noMAPI()
  606. leaveApplication
  607. 4s_SessionHandle
  608. logged 
  609. ' <> 
  610. SessionLogoff()
  611. unlinkMAPI
  612.     -- unlinkDLLs
  613. related functions
  614. -- Notes:
  615. -- Functions that are exported 
  616. z have 
  617. four 
  618. their 
  619. other 
  620. y used 
  621. Udefined 
  622. %OpenScript "
  623. -- handlers.
  624. -- The basic 
  625. need 
  626. access 
  627. examples 
  628. -- here.
  629. -- There 
  630. two structures 
  631. store recipients
  632. Recipient Structure
  633. -- Offset    Type    Element
  634. --    0        DWORD    
  635.  Must be 0
  636. --    4        
  637. JClass
  638. --    8        POINTER    Pointer 
  639. Name 
  640. --    12        
  641. Address 
  642. --    16        
  643. \Size 
  644. Entry ID 
  645. bytes
  646. --    20        
  647. buffer.
  648. Classes
  649. --    0 = 
  650.  originator
  651. --    1 = primary 
  652. --    2 = ropy 
  653. --    3 = blind 
  654. Message 
  655. --    0        
  656. --    4        
  657. Subject 
  658. --    8        
  659. ?Text 
  660. --    12        
  661. . NULL 
  662. mail.
  663. --    16        
  664. Date. Format 
  665. YYYY/MM/DD HH:MM
  666. --    20        
  667. Thread ID. Ignored 
  668. Hsome systems.
  669. --    24        
  670. Mail Flags
  671. --    28        
  672. Sender's 
  673. --    32        
  674. Number 
  675. --    36        
  676. array 
  677. --    40        
  678. file attachments
  679. --    44        
  680.  descriptors
  681.  returns TRUE 
  682. FALSE otherwise.
  683. IsMAPIAvailable
  684. -- According 
  685. spec, 
  686.  should 
  687. a non-zero "
  688. ;" entry
  689. Y [MAIL] section 
  690. WIN.INI 
  691. determine 
  692. support 
  693. does 
  694. z, just a 
  695. ma_GetWinIniVar("
  696. -- sessionLogOn() attempts 
  697. --    If the 
  698. successful, 
  699. "OK" 
  700. returned. Otherwise, s_MAPIError 
  701. SessionLogOn
  702. ZlphSession, retVal
  703. getWinPointer(4)
  704. MAPILogon(
  705. ,"","",1,0,
  706.         -- extract 
  707.  = PointerDWORD(0,
  708.  = str_OK()
  709.         -- 
  710. what error occured
  711. = getMAPIErrorString(
  712.     -- free 
  713. freeWinPointer (
  714. -- sessionLogOff() 
  715. [off 
  716. current 
  717. -- If 
  718. "OK" 
  719. SessionLogOff
  720. MAPILogoff(
  721. ,0,0)
  722.         -- discard 
  723.         -- 
  724. = GetMAPIErrorString(
  725. -- getting 
  726.      IDs
  727. -- getFirstMsgID() 
  728. appropriate type
  729. newMail 
  730. only considers unread 
  731. -- folder 
  732. considered.
  733.  logical 
  734.     ,s_MAPIerror
  735. ZlpMsgSeedID,lpMsgID
  736.  mailFlag
  737. xisType(
  738. ,s_sessionHandle)
  739. str_lostMAPI()
  740.     -- assign buffers 
  741.  flag
  742.  = 32
  743. MAPIFindNext(
  744. , 0, 0, 
  745.         -- 
  746. there 
  747. value
  748.         msgID = 
  749.  = getMAPIerrorString(
  750.         -- 
  751. -- getNextMsgID() 
  752. _ lastID,
  753.  = 32
  754. , 0, 0, 
  755.         -- 
  756.         -- 
  757. -- reading 
  758. -- getMsgName() reads 
  759. specified 
  760. sender. If 
  761. ZlpPtrMsg,
  762. ZlpSender,lpName
  763. ZmsgName
  764.     -- allocate a 
  765. recieve a 
  766. ("envelope") 
  767.     -- 0x00C0 = MAPI_ENVELOPE_ONLY + MAPI_PEEK
  768. MAPIReadMail(
  769.         -- 
  770.         -- 
  771. 0(28,
  772.         -- 
  773.         -- 
  774. MAPIFreeBuffer(
  775. allocated memory
  776. -- getMsgSub() 
  777. subject 
  778. . If 
  779. ZlpSubject
  780. ZmsgSub
  781.     -- 0
  782.         -- 
  783.         -- 
  784.         -- 
  785.         -- 
  786. -- getMsgDate() 
  787. was received. If 
  788. ZlpDate
  789. ZtmpDate,tmpTime
  790. ZmsgDate
  791.     -- 0
  792.         -- 
  793.         -- 
  794. 0(16,
  795.         -- 
  796.         -- 
  797.         -- reformat 
  798. default 
  799. "y/mm/dd"
  800. "h24:
  801. -- getMsgText() 
  802. . If 
  803. ZlpText
  804. ZmsgTxt
  805.  (ignore 
  806.     -- 0x0180 = 
  807.  + MAPI_SUPPRESS_ATTACH
  808.         msgText = 
  809.         -- 
  810.         -- 
  811.         -- 
  812.         -- 
  813. addresses
  814. -- getAddress() calls up 
  815. dialog box. If no 
  816. -- occurs 
  817. list 
  818. W chosen 
  819. ZlpPtrNum
  820. ZlpPtrRec,lpRec
  821.  recNum
  822.  recOffset
  823. ZrecNames
  824.     -- display 
  825. MAPIAddress(
  826. ,0,"",1,"",0,0,1,0,
  827.         -- retrieve 
  828.             -- 
  829.             -- 
  830. through 
  831.  = (i-1)* 24
  832. ) = 2
  833.             -- frre 
  834. names
  835. -- checkNames() takes a 
  836. partial 
  837. 1. If 
  838. > could be
  839. -- resolved 
  840. full mailing 
  841.  consists 
  842. containing 
  843. those 
  844. ZSTACK goodNames,badNames
  845. Xeach 
  846.         -- 
  847.         -- 0x0409 = MAPI_LOGON_UI + MAPI_DIALOG + MAPI_AB_NOMODIFY
  848. MAPIResolveName(
  849.             -- 
  850. pcannot be 
  851.             -- 
  852.             -- 
  853.             lpRecip = 
  854.             -- 
  855.             -- 
  856. valid 
  857.             -- 
  858. -- sending 
  859. -- composeMessage() displays 
  860. coposing
  861. D . If 
  862. "OK" 
  863. 4s_Sessionhandle,
  864. blank 
  865.     -- 0x0009 = 
  866. MAPISendMail(0,0,
  867. -- sendFile() opens 
  868.  mesage 
  869. -- attached 
  870. !. Null 
  871. -- "OK" 
  872. l fileName
  873. MAPISendDocuments(0, ";", 
  874. p, shortFileName(
  875. ), 0)
  876. -- sendMessage() sends a 
  877. "OK" 
  878. a recipent 
  879. -- ambiguous 
  880. user will be prompted 
  881. clarify
  882.  recips,
  883. ZlpBuff,lpTmp
  884. Zstack recipStack
  885.   numRec
  886. ZLONG count
  887.     -- find out many 
  888. "so enough 
  889.     -- can be 
  890.         -- a 
  891. *! which 
  892.         -- a 
  893.         -- a 
  894.         -- a 
  895.         -- a 
  896.     -- create a 
  897.     -- fill 
  898.         -- 
  899.         -- 
  900.         -- 0
  901. UI + 
  902. a%,0,
  903.             -- 
  904.             -- 
  905.             -- 
  906. contents 
  907.             -- optimization: 
  908. Windows 
  909. much faster
  910.             -- than stepping 
  911. ma_hmemcpy(
  912.             -- 
  913. z counter 
  914.             -- keep track 
  915. cleanup later
  916.  were 
  917.         -- 
  918. strings
  919.         -- 
  920. ,(32,
  921. 0(36,
  922.         -- 
  923. ,1,0)
  924. x! = 
  925.         -- 
  926.         -- pointers 
  927. }'stored 
  928. %a 2-
  929. order 
  930.         -- 
  931. necessary 
  932. grab 
  933. -- deleting 
  934. -- deleteMessage() removes 
  935. $ "OK 
  936. MAPIDEleteMail(
  937. ,0,0)
  938. -- Utility 
  939. 1#code associated 
  940. D# nErrorNumber
  941.         When 
  942. "Operation Succeded"            --SUCCESS_SUCCESS 
  943. "User Aborted"
  944. --MAPI_USER_ABORT 
  945. kFailed"            --MAPI_E_FAILURE
  946. "Login 
  947. 0    --MAPI_E_LOGIN_FAILURE 
  948. "Disk Full"
  949. --MAPI_E_DISK_FULL 
  950. "Insufficient Memory"        --MAPI_E_INSUFFICIENT_MEMORY 
  951. "Block Too Small"            --MAPI_E_BLK_TOO_SMALL 
  952. 5Many Sessions"            --MAPI_E_TOO_MANY_SESSIONS 
  953. ?Files"
  954. --MAPI_E_TOO_MANY_FILES 
  955. yRecipients"        --MAPI_E_TOO_MANY_RECIPIENTS 
  956. "Attacment Not Found"        --MAPI_E_ATTACHMENT_NOT_FOUND 
  957. "Failure Opening Attachment"    --
  958. LOPEN_FAILURE 
  959. ?Writing 
  960. |WRITE_FAILURE 
  961. "Unknown 
  962. +"            --MAPI_E_UNKNOWN_RECIPIENT 
  963. "Bad 
  964. ,"            --MAPI_E_BAD_RECIPTYPE 
  965. "No Messages"
  966. --MAPI_E_NO_MESSAGES 
  967. "Invalid 
  968. ;"            --MAPI_E_INVALID_MESSAGE 
  969. Large"            --MAPI_E_TEXT_TOO_LARGE 
  970. M/"            --MAPI_E_INVALID_SESSION 
  971. Supported"            --MAPI_E_TYPE_NOT_SUPPORTED 
  972. "Ambiguous 
  973. -"        --MAPI_E_AMBIGUOUS_RECIPIENT 
  974. g(:"&& 
  975. ;+a filename 
  976.  /has been stripped 
  977. path information
  978.  fName
  979. harCnt, i
  980.     charCnt = 
  981. - 1) 
  982. Vi+1 
  983. )) allocates a block 
  984. global 
  985. * nSize
  986. ZhMem,ptr
  987.  ma_globalAlloc(66,
  988. %) -- 66 
  989. Movable, Zero-Init
  990. str_noMem()
  991. ma_globalLock(
  992. )() frees 
  993. )lpPointer
  994. ma_Globalhandle(
  995. bitAnd 0x0000FFFF
  996. +selector.
  997. ma_GlobalUnLock(
  998.             retValue = ma_GlobalFree(
  999. 2() establishes a 
  1000. 2DLL 
  1001. --    a 
  1002. p' indicating 
  1003. found.
  1004.     sysS = 
  1005. provide messaging 
  1006. X"mapi.dll"
  1007. 1, STRING, 
  1008. I1, \
  1009. <2 MAPIDeleteMail (
  1010. .links 
  1011. kernel 
  1012. $ managment 
  1013.         INT     ma_globalUnlock=
  1014. %=globalFree(
  1015. H3     ma_globalHandle=
  1016. tbkwin 
  1017. k5 "tb40win.
  1018.     ma_getWinIniVar=
  1019. 5 disconnects 
  1020. str_noUnread
  1021. str_msgCountAll 
  1022. str_msgCountUnread 
  1023. !6"&&
  1024. J7            
  1025. I."&&\
  1026. e6Microsoft 
  1027. 7-compatible e-
  1028. 3 client software installed"&&\
  1029. 7 correctly."        
  1030. I."&&\
  1031. F,"&&\
  1032. 9wish 
  1033. str_notResolved
  1034. "These 
  1035. str_sent
  1036. str_notSent
  1037. str_notSubmit
  1038. "Report 
  1039. xsubmitted:"
  1040. str_submit
  1041. str_notDelete
  1042. xdeleted:"
  1043. str_noMessages
  1044. str_error
  1045. str_update
  1046. "Update 
  1047. str_cancel
  1048. "Cancel"
  1049. str_message
  1050. str_of
  1051. str_problemRep
  1052. "Problem 
  1053. "Aborting operation: 
  1054.  Allocation 
  1055. buttonClick
  1056. ZnameText,subText,scrollText
  1057. ZLONG msgNum
  1058. the ID 
  1059. unread message
  1060. getFirstMsgID(TRUE)
  1061.     -- repeat 
  1062. Zno more messages are found
  1063.     -- optimization: 
  1064. faster 
  1065. aincremental 
  1066. Fplace 
  1067. , than 
  1068. Qdirectly 
  1069. . In 
  1070. list 
  1071. generated one 
  1072. Fplaced 
  1073. fields 
  1074. complete.
  1075.         -- extract 
  1076. sender 
  1077.  = getMsgName(
  1078.         -- 
  1079. subject 
  1080.  = getMsgSub(
  1081.         -- 
  1082. places dummy 
  1083. (only 
  1084.         -- 
  1085. shows on th 
  1086.         -- 
  1087. technique allows you 
  1088.         -- much 
  1089. smoothly
  1090.         -- 
  1091. getNextMsgID(
  1092. str_noUnread()
  1093.         -- 
  1094. "Subject" = 
  1095. "ScrollBar" = 
  1096.     -- update the status 
  1097. updateMessages
  1098. 4LONG s_MsgCount,s_MsgNum
  1099.     -- initialize 
  1100. flist 
  1101. messages
  1102. initMessageList str_problemRep()
  1103. there 
  1104. )least one 
  1105. z > 0
  1106.         -- 
  1107. invalid reset 
  1108.  = 0 
  1109.         -- parse 
  1110. current 
  1111. parseMsgText
  1112.         -- 
  1113. browsing buttons
  1114.             enabled 
  1115. " = FALSE
  1116. " = TRUE
  1117. t" = 
  1118. t" = 
  1119. B"delete" = 
  1120.         -- 
  1121. are no 
  1122.  fields
  1123. "msgnum" = str_noMessages()
  1124. "address"
  1125. "department"
  1126. "office"
  1127. "phone"
  1128. "description"
  1129. "timestamp"
  1130.         -- 
  1131. t" = 
  1132. -- generate a 
  1133.  than contain 
  1134. filter 
  1135. their subjects
  1136. 4s_MsgHandles
  1137. 4s_MAPIerror
  1138. ZlastID
  1139. ZmsgSub
  1140. getFirstMsgID(
  1141. more 
  1142.         -- 
  1143.  = getMsgSub(
  1144.         -- 
  1145.         -- 
  1146. getNextMsgID(
  1147. -- take 
  1148. fill 
  1149. appropriate 
  1150. 4s_MAPIError
  1151. ZmsgTxt
  1152. ender 
  1153. getCurrentMsgName()
  1154. k&str_update() 
  1155. fstr_OK() 
  1156. str_cancel()
  1157.  = getCurrentMsgText()
  1158. &&str_of()&&
  1159.  = getCurrentMsgDate()
  1160.  returns 
  1161. getMsgName(
  1162. getMsgText(
  1163. getMsgDate(
  1164. initLinks
  1165. 3SessionLogon
  1166. isMAPIAvailable
  1167. str_noMAPI
  1168. enterApplication
  1169. unlinkDLLs
  1170. s_SessionHandle
  1171. USessionLogoff
  1172. unlinkMAPI
  1173. leaveApplication
  1174. reader
  1175. FALSE
  1176. ma_GetWinIniVar
  1177. clinkMAPI
  1178. IsMAPIAvailable
  1179. freeWinPointer
  1180. $bgetWinPointer
  1181. MAPILogon
  1182. s_SessionHandle
  1183. str_OK
  1184. DgetMAPIErrorString
  1185. s_MAPIError
  1186. SessionLogOn
  1187. s_SessionHandle
  1188. str_OK
  1189. MAPILogoff
  1190. DGetMAPIErrorString
  1191. s_MAPIError
  1192. SessionLogOff
  1193. .'+    +F
  1194. $bgetWinPointer
  1195. msgID
  1196. s_SessionHandle
  1197. MAPIFindNext
  1198. d3str_lostMAPI
  1199. DgetMAPIerrorString
  1200. s_MAPIerror
  1201. getFirstMsgID
  1202. .'+    +F
  1203. $bgetWinPointer
  1204. s_SessionHandle
  1205. lpMsgSeedID
  1206. MAPIFindNext
  1207. d3str_lostMAPI
  1208. DgetMAPIerrorString
  1209. s_MAPIerror
  1210. lpMsgID
  1211. getNextMsgID
  1212. .'+    +F
  1213. freeWinPointer
  1214. $bgetWinPointer
  1215. s_SessionHandle
  1216. 8aMAPIFreeBuffer
  1217. d3str_lostMAPI
  1218. DgetMAPIErrorString
  1219. s_MAPIerror
  1220. MAPIReadMail
  1221. getMsgName
  1222. .'+    +F
  1223. freeWinPointer
  1224. $bgetWinPointer
  1225. s_SessionHandle
  1226. 8aMAPIFreeBuffer
  1227. d3str_lostMAPI
  1228. DgetMAPIErrorString
  1229. s_MAPIerror
  1230. MAPIReadMail
  1231. getMsgSub
  1232. .'+    +F
  1233. freeWinPointer
  1234. $bgetWinPointer
  1235. s_SessionHandle
  1236. 8aMAPIFreeBuffer
  1237. y/mm/dd
  1238. d3str_lostMAPI
  1239. DgetMAPIErrorString
  1240. s_MAPIerror
  1241. h24:min
  1242. MAPIReadMail
  1243. getMsgDate
  1244. .'+    +F
  1245. freeWinPointer
  1246. $bgetWinPointer
  1247. s_SessionHandle
  1248. 8aMAPIFreeBuffer
  1249. d3str_lostMAPI
  1250. DgetMAPIErrorString
  1251. s_MAPIerror
  1252. msgText
  1253. MAPIReadMail
  1254. getMsgText
  1255. .'+    +F
  1256. ,&H.&
  1257. freeWinPointer
  1258. $bgetWinPointer
  1259. s_SessionHandle
  1260. recName
  1261. 8aMAPIFreeBuffer
  1262. MAPIAddress
  1263. d3str_lostMAPI
  1264. DgetMAPIErrorString
  1265. s_MAPIError
  1266. getAddress
  1267. .'+    +F
  1268. ,&H.&
  1269. freeWinPointer
  1270. $bgetWinPointer
  1271. s_SessionHandle
  1272. 8aMAPIFreeBuffer
  1273. MAPIResolveName
  1274. d3str_lostMAPI
  1275. DgetMAPIerrorString
  1276. s_MAPIError
  1277. checkNames
  1278. .'+    +F
  1279. freeWinPointer
  1280. $bgetWinPointer
  1281. s_Sessionhandle
  1282. str_OK
  1283. d3str_lostMAPI
  1284. DgetMAPIErrorString
  1285. s_MAPIError
  1286. MAPISendMail
  1287. composeMessage
  1288. .'+    +F
  1289. s_Sessionhandle
  1290. MAPISendDocuments
  1291. str_OK
  1292. HshortFileName
  1293. d3str_lostMAPI
  1294. DgetMAPIErrorString
  1295. s_MAPIError
  1296. sendFile
  1297. .'+    +F
  1298. freeWinPointer
  1299. $bgetWinPointer
  1300. ma_hmemcpy
  1301. s_Sessionhandle
  1302. str_OK
  1303. 8aMAPIFreeBuffer
  1304. MAPISendMail
  1305. MAPIResolveName
  1306. d3str_lostMAPI
  1307. DgetMAPIerrorString
  1308. s_MAPIError
  1309. recipient
  1310. sendMessage
  1311. .'+    +F
  1312. [MAPIDEleteMail
  1313. s_SessionHandle
  1314. str_OK
  1315. d3str_lostMAPI
  1316. DgetMAPIerrorString
  1317. s_MAPIError
  1318. deleteMessage
  1319. .',    "
  1320. .',    "
  1321. .',    "
  1322. .',    "
  1323. .',    "
  1324. .',    "
  1325. .',    "
  1326. .',    "
  1327. .',    "
  1328. .',    "
  1329. .',    "
  1330. .',    "
  1331. .',    "
  1332. .',    "
  1333. .',    "
  1334. .',    "
  1335. .',    "
  1336. .',    "
  1337. .',    "
  1338. .',    "
  1339. .',    "
  1340. Too Many Sessions
  1341. Too Many Files
  1342. Invalid Message
  1343. Block Too Small
  1344. Too Many Recipients
  1345. Failure Opening Attachment
  1346. Invalid Session
  1347. Attacment Not Found
  1348. Failure Writing Attachment
  1349. Bad Recipient Type
  1350. Type Not Supported
  1351. Insufficient Memory
  1352. No Messages
  1353. Disk Full
  1354. Login Failed
  1355. Operation Succeded
  1356. Text is Too Large
  1357. Unknown Recipient
  1358. User Aborted
  1359. Operation Failed
  1360. Unknown error:
  1361. Ambiguous Recipient
  1362. getMAPIErrorString
  1363. shortFileName
  1364. &ma_globalLock
  1365. str_noMem
  1366. Kma_globalAlloc
  1367. getWinPointer
  1368. retValue
  1369. !pma_Globalhandle
  1370. Memory error occured.  Operation Aborted.
  1371. ma_GlobalUnLock
  1372. } ma_GlobalFree
  1373. freeWinPointer
  1374. mapi.dll
  1375. MAPILogoff
  1376. MAPILogon
  1377. MAPIFindNext
  1378. MAPIFreeBuffer
  1379. MAPISendMail
  1380. MAPIReadMail
  1381. ,CUy er.'
  1382. MAPIResolveName
  1383. ,CU_Glo.'
  1384. MAPISendDocuments
  1385. MAPIAddress
  1386. MAPIDeleteMail
  1387. linkMAPI
  1388. getWinIniVar
  1389. ma_getWinIniVar
  1390. globalAlloc
  1391. ma_globalAlloc
  1392. globalLock
  1393. ma_globalLock
  1394. ,$U=    
  1395. globalUnlock
  1396. ma_globalUnlock
  1397. ,$T?Hpg-#
  1398. globalFree
  1399. ma_globalFree
  1400. globalHandle
  1401. ma_globalHandle
  1402. ,#U_=    
  1403. hmemcpy
  1404. ma_hmemcpy
  1405. tb40win.dll
  1406. kernel
  1407. initLinks
  1408. mapi.dll
  1409. unlinkMAPI
  1410. tb40win.dll
  1411. kernel
  1412. unlinkDLLs
  1413. You have no unread messages.
  1414. str_noUnread
  1415. You have
  1416. messages.
  1417. str_msgCountAll
  1418. unread messages.
  1419. You have
  1420. str_msgCountUnread
  1421. MAPI is not available at this time.
  1422. You need to have Microsoft Mail or MAPI-compatible e-mail client software installed
  1423. for the examples in this book to function correctly.
  1424. str_noMAPI
  1425. The examples in this book will not function correctly,
  1426. MAPI is not available at this time.
  1427. you may wish to exit.
  1428. str_lostMAPI
  1429. str_OK
  1430. These names could not be resolved:
  1431. str_notResolved
  1432. Message sent.
  1433. str_sent
  1434. Message not sent:
  1435. str_notSent
  1436. Report not submitted:
  1437. str_notSubmit
  1438. Report submitted.
  1439. str_submit
  1440. Message not deleted:
  1441. str_notDelete
  1442. No messages
  1443. str_noMessages
  1444. Error:
  1445. str_error
  1446. Update Messages?
  1447. str_update
  1448. Cancel
  1449. str_cancel
  1450. Message
  1451. str_message
  1452. str_of
  1453. Problem Report
  1454. str_problemRep
  1455. Aborting operation: Memory Allocation Error.
  1456. str_noMem
  1457. .'+    +F
  1458. .&,    7
  1459. .'+    +F
  1460. (str_noUnread
  1461. l'getNextMsgID
  1462. ScrollBar
  1463. getMsgSub
  1464. 1RgetFirstMsgID
  1465. Subject
  1466. getMsgName
  1467. buttonClick
  1468. uupdateMessages
  1469. enterPage
  1470. +&,""
  1471. +&,">
  1472. +&,""
  1473. .'+&?
  1474. problem
  1475. s_MsgNum
  1476. phone
  1477. address
  1478. description
  1479. str_noMessages
  1480. previous
  1481. delete
  1482. 8parseMsgText
  1483. initMessageList
  1484. msgnum
  1485. office
  1486. department
  1487. timestamp
  1488. str_problemRep
  1489. s_MsgCount
  1490. updateMessages
  1491. .'+    +F
  1492. .'+&?
  1493. +&,"Y
  1494. +&,I3
  1495. .'+    +F
  1496. FALSE
  1497. l'getNextMsgID
  1498. getMsgSub
  1499. s_MsgHandles
  1500. 1RgetFirstMsgID
  1501. s_MsgCount
  1502. initMessageList
  1503. w,    #>
  1504. +&,    #?
  1505. w,    #?
  1506. +&,    #?
  1507. address
  1508. s_MAPIError
  1509. phone
  1510. str_cancel
  1511. description
  1512. 'getCurrentMsgText
  1513. str_message
  1514. getCurrentMsgDate
  1515. problem
  1516. uupdateMessages
  1517. str_OK
  1518. getCurrentMsgName
  1519. msgnum
  1520. str_update
  1521. str_of
  1522. s_MsgNum
  1523. Error:
  1524. office
  1525. department
  1526. timestamp
  1527. s_MsgCount
  1528. parseMsgText
  1529. +&,I3
  1530. s_MsgNum
  1531. s_MsgHandles
  1532. getMsgName
  1533. getCurrentMsgName
  1534. +&,I3
  1535. getMsgText
  1536. s_MsgNum
  1537. s_MsgHandles
  1538. getCurrentMsgText
  1539. +&,I3
  1540. s_MsgNum
  1541. s_MsgHandles
  1542. getMsgDate
  1543. getCurrentMsgDate
  1544. str_submit
  1545. str_notDele
  1546. examples
  1547. in,true
  1548. ThreeDeeRect
  1549. text area
  1550. bottomLine
  1551. topLine
  1552. description
  1553. description
  1554. enterpage
  1555. doesn't fit, 
  1556. notifybefore 
  1557. "description" 
  1558. Front
  1559. front
  1560. enterpage
  1561. handler keeps the title 
  1562. synchronized
  1563. notifybefore 
  1564. "front" 
  1565. buttonClick
  1566. enterPage
  1567. buttonClick
  1568. -- determine 
  1569. navigation 
  1570. should be allowed
  1571. notifybefore 
  1572. on a different 
  1573. oenabled = (
  1574. Previous
  1575. buttonClick
  1576. enterPage
  1577. .one 
  1578. buttonClick
  1579. -- determine 
  1580. navigation 
  1581. should be allowed
  1582. notifybefore 
  1583. on a different 
  1584. oenabled = (
  1585. main menu
  1586. buttonClick
  1587. main menu
  1588. enterPage
  1589. the main 
  1590. buttonClick
  1591. -- determine 
  1592. Bnavigation 
  1593. Ienu 
  1594. should be allowed:
  1595. notifybefore 
  1596. ycurrent 
  1597. oenabled = (
  1598. in,true
  1599. ThreeDeeRect
  1600. work area
  1601. bottomLine
  1602. topLine
  1603. enterPage
  1604. main menu
  1605. -- a notify handler was used 
  1606. update 
  1607. you enter 
  1608. Main Menu
  1609. Main Menu
  1610. buttonClick
  1611. ,&H.&
  1612. front
  1613. enterpage
  1614. buttonClick
  1615. ZLONG lineNum
  1616.     -- determine which 
  1617. Uwas selected 
  1618. * = selectedTextlines 
  1619. that 
  1620. -- update the 
  1621. list 
  1622. notifybefore 
  1623. ZSTRING newText
  1624.     -- generate a 
  1625.     -- optimization: 
  1626. faster 
  1627. aincremental 
  1628. place 
  1629. , than 
  1630.     -- directly 
  1631. B(i-1) 
  1632. J"front" 
  1633. Using MAPI
  1634. Linking to MAPI.DLL
  1635. Looking up Addresses
  1636. Verifying Names
  1637. Checking For Unread Mail
  1638. Counting Messages
  1639. Composing Mail
  1640. Sending Messages
  1641. Example: Problem Reports
  1642. Choose one of these topics:low by clicking on its name:
  1643. enterpage
  1644. Example: Problem Reports
  1645. Example: Problem Reports
  1646. Example: Problem Reports+
  1647. The following two examples demonstrate how a small MAPI application, such as a custom e-mail form, might be built in ToolBook. 
  1648. The first example is a guided input form for submitting problem reports. The user simply fills in the blanks and clicks on a button to submit the report.
  1649. The second example scans the user's incoming mail folder for problem reports submitted using the e-mail form. This provides a simple interface for browsing through these messages...................................
  1650. Submit Reports
  1651. examples
  1652. Submit Reports
  1653. buttonClick
  1654. buttonClick
  1655.     -- display a 
  1656. example
  1657. "examples"
  1658.     currentpage 
  1659. "Submit Reports"
  1660. &Submit Reports
  1661. Receive Reports
  1662. Receive Reports
  1663. examples
  1664. buttonClick
  1665. buttonClick
  1666.     -- display a 
  1667. example
  1668. "examples"
  1669.     currentpage 
  1670. "Receive Reports"
  1671. &Receive Reports
  1672. main menu
  1673. right
  1674. grey all
  1675. grey left
  1676. grey right
  1677. Looking up Addresses
  1678. -- a notify handler was used 
  1679. the address 
  1680. you enter 
  1681. Looking up Addressesok]
  1682. Looking up Addressesokkess Book
  1683. Click Look Up Address to display the dialog box MAPI provides for choosing addresses. Names you select from the list will be placed in the field below...........................
  1684. Look Up Address
  1685. nameList
  1686. getAddress
  1687. s_MAPIError
  1688. buttonClick
  1689. buttonClick
  1690. 4s_MAPIError
  1691. up the Address Book dialog 
  1692. retrieve a list 
  1693. names
  1694.     nameList = getAddress()
  1695. returned - 
  1696. error condition
  1697. &Look Up Address
  1698. enterPage
  1699. notifybefore 
  1700. enterPage
  1701. .'+    +F
  1702. }str_sent
  1703. getAddress
  1704. sendMessage
  1705. s_MAPIError
  1706. str_notSe
  1707. uttonClick
  1708. buttonClick
  1709. 4s_MAPIError
  1710. there 
  1711. no recipient supplied
  1712.         -- call up 
  1713. 6 Address Book
  1714. getAddress()
  1715.         -- 
  1716. we don't 
  1717. address we won't 
  1718. a message
  1719.         -- fill 
  1720.  appropriate 
  1721.